package com.eagle.functioninterface;

import org.junit.Test;

import java.util.Objects;
import java.util.function.UnaryOperator;

/**
 * {@link java.util.function.UnaryOperator} 函数式接口是 {@link java.util.function.Function} 接口的实现
 * 主要就是解决一元同类事物之间的转化
 *
 * @author qinlinsen
 */
public class UnaryOperatorTest12 {
    @Test
    public void testUnaryOperator(){
        Integer result = compute(3, x -> x + 3);
        System.out.println(result);
    }

    private <T> T compute(T input, UnaryOperator<T> processor){
        Objects.requireNonNull(processor);
        T result = processor.apply(input);
        return result;
    }
}
